package src.cs2340.todoApp;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * DateComparatorTest.java
 * Will check the compare method in DateComparator.
 */

public class DateComparatorTest {
	Location home, work, colombia;
	Date today, tomorrow, past;
	TaskItem t1, t2, t3;
	DateComparator d;
	
	@Before
	public void setup() throws Exception{}
	
	/**
	 * @author Rochelle
	 * This tests the compare method in Date to make sure what is being compared returns the 
	 * right sign of value.  Will check if two tasks of the same due date return 0 when compared
	 * to each other.  Is a positive number returned when the left task is greater than the right?
	 * How about a negative number when the left task occurred before the right task?
	 */
	@Test
	public void testCompare() {
		d = new DateComparator();
		
		Location home = new Location("home", 1427, "Big Wide Road", "Kristiantown", "CA", 99999);
		Date today = new Date(2, 4, 2012, 00, 12, Date.Meredian.AM);
		TaskItem t1 = new TaskItem("sleep", home, today, "seriously dude, get some sleep", 
				"home", false);
		

		Location work = new Location("GA Tech", 225, "North Avenue", "Atlanta", "GA", 30332);
		Date tomorrow = new Date(2, 4, 2012, 11, 00, Date.Meredian.AM);
		TaskItem t2 = new TaskItem("do cs2340", work, tomorrow, "Stop worrying about " + 
				"not updating to HEAD and get those JUnit tests DONE!!!", "school", false);
		
		
		Location colombia = new Location("horse farm", 5555, "Colombia Rd",
				"Bogota", "Colombia", 55555);
		Date past = new Date(18, 12, 1896, 4, 00, Date.Meredian.PM);
		TaskItem t3 = new TaskItem("business venture", colombia, past, "Go like a boss" + 
				"to Manfred's grandfather's farm", "work", true);
		
		TaskItem t4 = new TaskItem("do cs2110", work, tomorrow, "Start early or else...",
			"school", false);
		
		
		assertEquals("Should be less than 0 but was " + d.compare(t1, t2), 
				d.compare(t1, t2), -1088);
		assertEquals("Should be 0 but was " + d.compare(t2, t4), d.compare(t2, t4), 0);
		assertEquals("Should be greater than 0 but was" + d.compare(t2, t3), d.compare(t2, t3), 116);
		assertEquals("Should be still greater than 0 for compareTo because task 4 happened before" +
				"task 1" + d.compare(t4, t1), d.compare(t4, t1), 1088);
	}

}
